Page({
  data: {},
  onShow: function () {

  },
  onLoad: function (t) {
    var _ = this;
    //查看职位
    wx.request({
      url: 'https://zg99.offcn.com/index/chaxun/getjllist?actid=51125&callback=?',
      data: {
        phone: wx.getStorageSync('51125phone'),
        tabnum: 1,
        limits: 20,
        sstimes: new Date().getTime(),
      },
      success(res) {
        var jsonStr = res.data;
        jsonStr = jsonStr.replace("(", "");
        jsonStr = jsonStr.replace(")", "");
        if (typeof jsonStr != 'object') {
          jsonStr = jsonStr.replace(/\ufeff/g, ""); //字符串转化JSON对象
          var theJson = JSON.parse(jsonStr);
        }
        console.log(theJson.lists)
        _.setData({
          myList: theJson.lists,
          success: 1
        })
        console.log(_.data.myList, "收藏数据");
      }
    })
  },

  jobInfo(e) {
    var {
      zdy
    } = e.currentTarget.dataset
    wx.navigateTo({
      url: "../jobInfo/jobInfo?zdy=" + zdy
    });
  },
  //取消收藏职位
  qxsczw: function (e) {
    var _ = this;
    console.log(e);
    wx.request({
      url: 'https://zg99.offcn.com/index/chaxun/deletelogs?actid=51125&callback=?',
      data: {
        phone: wx.getStorageSync('51125phone'),
        zdy: e.currentTarget.dataset.zdy,
        id: e.currentTarget.dataset.id,
        sstimes: new Date().getTime(),
      },
      success(res) {
        var jsonStr = res.data;
        jsonStr = jsonStr.replace("(", "");
        jsonStr = jsonStr.replace(")", "");
        if (typeof jsonStr != 'object') {
          jsonStr = jsonStr.replace(/\ufeff/g, ""); //字符串转化JSON对象
          var theJson = JSON.parse(jsonStr);
        }
        console.log(theJson)
        if (theJson.status == 1) {
         
          wx.showToast({
            title: '取消收藏成功！',
            duration: 2000
          })
         
        } else {
          wx.showToast({
            title: '取消收藏失败！',
            icon: 'none',
            duration: 2000
          })
        }
        _.onLoad()
      }
    })
  },



  gozx: function () {
    wx.navigateTo({
      url: '../../xiaoneng/xiaoneng',
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    var area = wx.getStorageSync('area')
    var agent = wx.getStorageSync('agent')
    var page = wx.getStorageSync('page')
    return {
      title: '2023国家公务员招录考试职位表',
      path: 'pages/gk/zwcx/search/search/search?area=' + area + '&agent=' + agent + '&page=' + page
    }
  },
  /**分享到朋友圈*/
  onShareTimeline: function () {
    var area = wx.getStorageSync('area')
    var agent = wx.getStorageSync('agent')
    var page = wx.getStorageSync('page')
    return {
      title: '2023国家公务员招录考试职位表',
      path: 'pages/gk/zwcx/search/search/search?area=' + area + '&agent=' + agent + '&page=' + page
    }
  }
});